/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elderberryni2.data.container;

import elderberryni2.abstracts.BaseTimestampable;
import elderberryni2.interfaces.IDumpable;

/**
 *
 * @author warringer
 */
public class VelocityContainer extends BaseTimestampable<Float>
    implements Comparable<VelocityContainer>, IDumpable {

    private float velX;
    private float velY;
    private float velZ;
    private float velVector;

    /**
     * 
     * @param velX
     * @param velY
     * @param velZ
     * @param timestamp
     */
    public VelocityContainer(float velX, float velY, float velZ, float timestamp) {
        this.velX = velX;
        this.velY = velY;
        this.velZ = velZ;
        this.velVector = (float) Math.sqrt(velZ*velZ + velY*velY + velX*velX);
        this.setTimestamp(timestamp);
    }

    /**
     * 
     * @return
     */
    public float getVelVector() {
        return velVector;
    }

    /**
     * 
     * @return
     */
    public float getVelX() {
        return velX;
    }

    /**
     * 
     * @return
     */
    public float getVelY() {
        return velY;
    }

    /**
     * 
     * @return
     */
    public float getVelZ() {
        return velZ;
    }
    
    @Override
    public Float getTimestampDifference(Float timestamp) {
        return Math.abs(this.getTimestamp() - timestamp);
    }

    /**
     * 
     * @param t
     * @return
     */
    @Override
    public int compareTo(VelocityContainer t) {
        if (this.velX == t.getVelX() && 
                this.velY == t.getVelY() &&
                this.velZ == t.getVelZ()) {
            return 0;
        } else {
            return 1;
        }
    }

    @Override
    public String toCSV() {
        return new Float(velX).toString() 
                + ";" + new Float(velY).toString() 
                + ";" + new Float(velZ).toString() 
                + ";" + new Float(velVector).toString();
    }

    @Override
    public String getHeader() {
        return "Velocity X;Velocity Y;Velocity Z;Velocity Vector";
    }
    
}
